package com.doudoukeji.service.Activity.my.edituser;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.doudoukeji.service.Activity.my.edituser.edituserinf.EditUserInfActivity;
import com.doudoukeji.service.Activity.my.edituser.editusername.NameEditorActivity;
import com.doudoukeji.service.Activity.my.edituser.edituserphone.PhoneNumActivity;
import com.doudoukeji.service.Activity.myhospital.HospitalListActivity;
import com.doudoukeji.service.Bean.HospitalLitapal;
import com.doudoukeji.service.Bean.ServiceLitapal;
import com.doudoukeji.service.Bean.Token;
import com.doudoukeji.service.R;
import com.sanhai.android.mvp.EduActivity;

import org.apache.commons.lang3.StringUtils;

/**
 * @version 2.0
 * @类描述：选择要修改的内容
 * @项目名称：ddgh
 * @类名称： editUserInfoActivity
 * @包名称： com.doudoukeji.service.Activity.my.edituser
 * @创建人： zhanjunjie
 * @创建时间：2016/3/10 14:28
 * @修改人：
 * @修改时间：2016/3/10 14:28
 * @修改备注： new parent class(用一句话描述修改了什么)
 */
public class editUserInfoActivity extends EduActivity {

    //标题
    private TextView mTvTitle, mTvName, mTvPhone, mTvProject, mTvInfirmary;

    @Override
    public void init() {
        // 设置标题
        mTvTitle = (TextView) findViewById(R.id.tv_title);
        mTvTitle.setText("信息编辑");

        findViewById(R.id.rl_username).setOnClickListener(this);
        findViewById(R.id.rl_userphone).setOnClickListener(this);
        findViewById(R.id.rl_userproject).setOnClickListener(this);
        findViewById(R.id.rl_userinfirmary).setOnClickListener(this);

        mTvName = (TextView) findViewById(R.id.tv_user_name);
        mTvPhone = (TextView) findViewById(R.id.tv_user_phone);
        mTvInfirmary = (TextView) findViewById(R.id.tv_user_infirmary);
        mTvProject = (TextView) findViewById(R.id.tv_user_project);

        initData();




    }

    @Override
    protected void onResume() {
        super.onResume();
        initData();
    }

    /**
     * 初始化界面数据
     */
    private void initData() {
        mTvName.setText(Token.getName());
        mTvPhone.setText(Token.getPhone());


        if (StringUtils.isNotBlank(Token.getServices())){
            if (StringUtils.isNotBlank(ServiceLitapal.getServiceIdName(Token.getServices()))){
                mTvProject.setText(ServiceLitapal.getServiceIdName(Token.getServices()).substring(0, ServiceLitapal.getServiceIdName(Token.getServices()).lastIndexOf(",")));
            }

        }else{
            mTvProject.setText("请选择服务项目");
        }

        if (StringUtils.isNotBlank(Token.getHospitals())){
            if (StringUtils.isNotBlank(HospitalLitapal.getHospitalIdName(Token.getHospitals()))){
                mTvInfirmary.setText(HospitalLitapal.getHospitalIdName(Token.getHospitals()).substring(0, HospitalLitapal.getHospitalIdName(Token.getHospitals()).lastIndexOf(",")));
            }
        }else{
            mTvInfirmary.setText("请选择医院");
        }
    }

    @Override
    public void onClickEvent(View view) {
        switch (view.getId()) {
            case R.id.rl_username: {
                Intent intent = new Intent(this, NameEditorActivity.class);
                startActivity(intent);
            }
            break;
            case R.id.rl_userphone: {
                Intent intent = new Intent(this, PhoneNumActivity.class);
                startActivity(intent);
            }
            break;
            case R.id.rl_userproject: {
                Intent intent = new Intent(this, EditUserInfActivity.class);
                startActivity(intent);

            }
            break;
            case R.id.rl_userinfirmary: {
                Intent intent = new Intent(this, HospitalListActivity.class);
                startActivity(intent);
            }
            break;
        }
    }



    @Override
    public void setContentLayout() {
        setContentView(R.layout.activity_edituserinfo);
    }
}
